# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=golang-golang-x-sync
pkgver=0.0.20220819
_commit=7fc1605a5dde7535a0fc1770ca44238629ff29ac
pkgrel=1
pkgdesc='Go concurrency primitives in addition to the ones provided by the language and "sync" and "sync/atomic" packages'
arch=('any')
url="https://github.com/golang/sync"
license=('BSD')
depends=('go')
source=("$pkgname-$_commit.tar.gz::https://github.com/golang/sync/archive/$_commit.tar.gz")
sha512sums=('9dca92721fd7e71b077d1d1cc2728383db736805a2185aa8bd2c672cdb963325defe4af74b74c207ac70fdde868a642556c83f75de8f4bc833c5acadf986f425')

check() {
  export GO111MODULE=off
  export GOPATH="$srcdir/build:/usr/share/gocode"
  mkdir -p "$srcdir"/build/src/golang.org/x
  cp -a "$srcdir"/sync-$_commit "$srcdir"/build/src/golang.org/x/sync
  cd "$srcdir"/build/src/golang.org/x/sync
  go test -v $(go list ./...)
}

package() {
  mkdir -p "$pkgdir"/usr/share/gocode/src/golang.org/x
  cp -a "$srcdir"/sync-$_commit "$pkgdir"/usr/share/gocode/src/golang.org/x/sync

  install -Dm644 sync-$_commit/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
